# from django.test import TestCase

# Create your tests here.

import unittest
import requests

class CmdHistory(unittest.TestCase):
    @classmethod
    def setUpClass(cls) -> None:
        print('before class')

    def setUp(self) -> None:
        print('before unittest')

    def test_list_history(self):
        """测试查看命令历史的API接口是否成功"""
        respone = requests.get('http://127.0.0.1:8000/v1/task/cmdhistory/')
        self.assertEqual(respone.status_code, 200)
        self.assertIsNotNone(respone.json().get('results'))

    def test_list_history_detail(self):
        """测试查看命令历史详情的API接口是否成功"""
        respone = requests.get('http://127.0.0.1:8000/v1/task/cmdhistory/1/')
        self.assertEqual(respone.status_code, 200)
        respone = requests.get('http://127.0.0.1:8000/v1/task/cmdhistory/100000/')
        self.assertEqual(respone.json().get('code'), 404)



    def tearDown(self) -> None:
        print('after unittest')

    @classmethod
    def tearDownClass(cls) -> None:
        print('after class')


if __name__ == '__main__':
    unittest.main()
